<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>首页编辑</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link href="${ctxPath}/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<script src="${ctxPath}/static/admin/js/plugins/sweetalert/sweetalert.min.js"></script>
	<link rel="shortcut icon" href="${ctxPath}/views/admin/favicon.ico">
	<link href="${ctxPath}/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="${ctxPath}/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="${ctxPath}/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="${ctxPath}/static/admin/css/animate.css" rel="stylesheet">
	<link href="${ctxPath}/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="${ctxPath}/static/admin/css/plugins/webuploader/webuploader.css" rel="stylesheet">
	<style>
		#category_info{resize:none;}
	</style>
</head>

<body class="gray-bg">

	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>首页信息</h5>
						<div class="ibox-tools">
							<a class="close-link" href="${ctxPath}/home/index">
								<button type="button" class="btn btn-default btn-sm"
									style="position: absolute; margin-bottom: 0px; bottom: 0px; right: 0px;">返回上一页</button>
							</a>
						</div>
					</div>
					<div class="ibox-content">
						<form action="${ctxPath}/home/save" method="post" name="form" id="form" class="form-horizontal" enctype="multipart/form-data">
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label">首页图片</label>
								<div id="uploader-demo">
                                	<label>
                                		<p class="webuploader-pick">选择图片</p><p style="color:red;">(请选用 1920 * 500 尺寸的图片)</p>
                                		<input id="file" type="file" name="pic" onchange="goodsImg(this)" style="display:none;">
                                		<input type="hidden" id="id" name="id"  value="${data.id!}">
                                	</label>
								</div>
							</div>
							<div class="form-group" style="dispaly:none;">
                            	<label class="col-sm-2 control-label" style="margin-right:16px;"></label>
                            	<div id="imgDiv">
                            		<!--# if(data.img! != ""){ -->
                            			<img src="${ctxPath}/down/downHomeImg?imgUrl=${data.img!}" style="width:1080px; height:500px;"/>
                            		<!--# } -->
                            		<input type="hidden" id="imgFix" name="imgFix" value="${data.img!}"/>
                            	</div>
                            </div>
                            <div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label">图片排序</label>
								<div class="col-sm-10">
									<div class="row">
										<div class="col-md-2">
											<input type="text" placeholder="分类排序" class="form-control"
												id="sort" name="sort" value="${data.sort!}" onblur="num_check($(this).val())">
										</div>
									</div>
								</div>
							</div>
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<button id="btn_save" type="button" class="btn btn-primary" >保存内容</button>
									<a href="${ctxPath}/home/index" class="btn btn-white">取消</a>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>



	<!-- 全局js -->
	<script src="${ctxPath}/static/admin/js/jquery.min.js?v=2.1.4"></script>
	<script src="${ctxPath}/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
	<script src="${ctxPath}/static/admin/js/plugins/webuploader/webuploader.js"></script>
    <script src="${ctxPath}/static/js/ajaxfileupload.js"></script>

	<!-- 自定义js -->
	<script src="${ctxPath}/static/admin/js/content.js?v=1.0.0"></script>

	<!-- iCheck -->
	<script src="${ctxPath}/static/admin/js/plugins/iCheck/icheck.min.js"></script>
	<script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
	<script type="text/javascript">
		function num_check(a){
	        var m =a ;
			var partten =/^\+?(0|[1-9][0-9]*)$/;
			if (m != '') {
				if (!partten.test(m)) {
					swal({
						  title: "提示",
						  text: "请输入整数",
						  timer: 1000,
						  showConfirmButton: false
						});
					return false;
				}
			}
		}
		
		//图片预览及上传
        function goodsImg(file){
        	var imgDiv = document.getElementById('imgDiv');
        	console.log(file.value);
        	if (file.files && file.files[0]){
        		var reader = new FileReader();
        		reader.onload = function(evt){
        			imgDiv.innerHTML = '<img src="' + evt.target.result + '" style="width:1080px; height:500px;"/><input type="hidden" id="imgFix" name="imgFix" value=""/>';
        		}
        		reader.readAsDataURL(file.files[0]);
        	}else{
        		imgDiv.innerHTML = '<div id="imgFix" class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
        	}
        }
		
		
      //提交
      $("#btn_save").on("click", function(){
    	  if($("#sort").val() == "" || $("#sort").val() == null){
    		  	swal({
				  title: "提示",
				  text: "排序不可为空",
				  timer: 1000,
				  showConfirmButton: false
				});
    		  	return false;
    	  }
    	  $("#form").submit();
      })
	</script>



</body>

</html>
